package gold.digger;

import gold.utils.InputUtil;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC868 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int binaryGap(int n) {
            String s = Integer.toBinaryString(n);
            int pre = -1;
            int max = 0;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == '1') {
                    if (pre == -1) {
                        pre = i;
                    } else {
                        max = Math.max(i - pre, max);
                        pre = i;
                    }
                }
            }
            return max;
        }
    }


    public void run() {
        int[] arr = InputUtil.toIntegerArray("[1,2,3]");
        System.out.println(new Solution().toString());
    }

    public static void main(String[] args) throws Exception {
        LC868 an = new LC868();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
